package com.appbee.songs.client.activity;

import javax.inject.Inject;

import com.appbee.songs.client.presenter.impl.ShowYoutubePlayerSongSelectionPresenter;
import com.appbee.songs.client.presenter.impl.SongsDataPresenter;
import com.appbee.songs.client.ui.ISongsTableView;
import com.google.gwt.activity.shared.AbstractActivity;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.ui.AcceptsOneWidget;

public class SongsTableActivity extends AbstractActivity
{
	private final SongsDataPresenter dataPresenter;
	private final ISongsTableView tableView;

	@Inject
	public SongsTableActivity(	ISongsTableView tableView,
								SongsDataPresenter dataPresenter,
								ShowYoutubePlayerSongSelectionPresenter selectionPresenter)
	{
		this.tableView = tableView;
		this.dataPresenter = dataPresenter;
		dataPresenter.setView(tableView);
		selectionPresenter.setView(tableView);
	}

	@Override
	public void start(AcceptsOneWidget panel, EventBus eventBus)
	{
		dataPresenter.start();
		panel.setWidget(tableView);
	}

	@Override
	public void onStop()
	{
		dataPresenter.onStop();
	}

}
